# 如果不限次数买卖

class Solution:
    def maxProfit(self, prices) -> int:
        profits = [0]
        for i in range(1, len(prices)):
            tmp = []
            for j in range(len(profits)):
                if prices[i] > prices[j]:
                    tmp.append(profits[j] + prices[i] - prices[j])
                else:
                    tmp.append(profits[j])
            profits.append(max(tmp))
        return profits[-1]

if __name__ == '__main__':
    nums = [7,1,5,3,6,4]
    s = Solution()
    print(s.maxProfit(nums))